<?php
require_once 'DBConnecter.inc';
class Category extends DBConnecter {
	public $category;
	public $item_tp;
	public $item_value;
	function __construct() {
		$this->connectDB ();
	}
	public function printCategory($val) {
		echo "<option value='" . $this->item_tp . "'";
		if ($val == $this->item_tp) {
			echo " selected='selected'";
		}
		echo ">" . $this->item_value . "</option>";
	}
public function search4table($category, $val) {
		$sql = "CALL ".self::CONST_DB.".data_dic_info('1', '" . $category . "', '', '');select @out_err_cd, @out_err_msg;";
		// echo $sql;
		$retval = null;
		$retval = array ();
// 		if ($category == 5) {
// 			// 차량 없는 경우를 위해 빈 값 하나 생성
// 			echo "<option value=''>차량 없음</option>";
// 		}
//		DB Fucntion에서 '없음'값 내려주기로 변경
// else if ($category == 9){
// 			// 차량 없는 경우를 위해 빈 값 하나 생성
// 			echo "<option value=''>해당사항 없음</option>";
// 		}
		
		if ($rs = $this->getMySqlConneter ()->multi_query ( $sql )) {
			if ($rs != null && $rs = $this->getMySqlConneter ()->use_result ()) {
				while ( $row = $rs->fetch_row () ) {
					$this->item_tp = $row ['0'];
					$this->item_value = $row ['1'];
					$this->printCategory ( $val );
				}
				$rs->free ();
			}
		}
	}
	public function eval_search4table($table,$category, $val) {
		
		$sql = "CALL ".self::CONST_DB.".data_dic_info('".$table."', '" . $category . "', '','');select @out_err_cd, @out_err_msg;";
		//echo $sql;
		$retval = null;
		$retval = array ();
		if ($rs = $this->getMySqlConneter ()->multi_query ( $sql )) {
			if ($rs != null && $rs = $this->getMySqlConneter ()->use_result ()) {
				while ( $row = $rs->fetch_row () ) {
					$this->item_tp = $row ['0'];
					$this->item_value = $row ['1'];
					$this->printCategory ( $val );
				}
				$rs->free ();
			}
		}
	}
	public function createCategory($category, $item_value) {
		if ($category == "1" or $category == "2") {
			$sql = "CALL ".self::CONST_DB.".data_dic_info('2', '" . $category . "','" . $item_tp . "','" . $item_value . "');select @out_err_cd, @out_err_msg;";
			// echo $sql;
		} else if ($category == "3") {
			// 지점
			$sql = "CALL ".self::CONST_DB.".data_dic_info('4', '" . $category . "','" . $item_tp . "','" . $item_value . "');select @out_err_cd, @out_err_msg;";
			// echo $sql;
		} else if ($category == "5") {
			// 거래처
			$sql = "CALL ".self::CONST_DB.".data_dic_info('5', '" . $category . "','" . $item_tp . "','" . $item_value . "');select @out_err_cd, @out_err_msg;";
			// echo $sql;
		} else if ($category == "7") {
			// 용차
			$sql = "CALL ".self::CONST_DB.".data_dic_info('7', '" . $category . "','" . $item_tp . "','" . $item_value . "');select @out_err_cd, @out_err_msg;";
			// echo $sql;
		}
		
		$rs = $this->getMySqlConneter ()->multi_query ( $sql );
	}
	public function deleteCategory($category, $item_tp, $item_value) {
		if ($category == "1" or $category == "2") {
			$sql = "CALL ".self::CONST_DB.".data_dic_info('3','" . $category . "','" . $item_tp . "','" . $item_value . "');select @out_err_cd, @out_err_msg;";
			// echo $sql;
		} elseif ($category == "8") {
			$sql = "CALL ".self::CONST_DB.".data_dic_info('8','" . $category . "','" . $item_tp . "','" . $item_value . "');select @out_err_cd, @out_err_msg;";
			// echo $sql;
		} else {
			$sql = "CALL ".self::CONST_DB.".data_dic_info('6','" . $category . "','" . $item_tp . "','" . $item_value . "');select @out_err_cd, @out_err_msg;";
			// echo $sql;
		}
		
		$rs = $this->getMySqlConneter ()->multi_query ( $sql );
	}
}
?>

